package com.mochasoft.shangchm.type;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

import com.mochasoft.shangchm.analyzer.Analyzer;

public class DoubleColorBall extends CaiPiao {

	private Set results;

	public DoubleColorBall(){
		this.results = new HashSet();
	}

	public Set getResult(int i) {
		for(int n =i;i>0;i--){
			results.add(getOneResult());
			System.out.println("-----------------------------");
		}
		return results;	
	}
	
	private String getOneResult(){
		boolean isBad = true;
		TreeSet group = null;
		while(isBad){
			group = creatGroupNumbers(getFilter(),getSize(),getMaxNumber());
			if(getAnalyzers() == null){
				return group.toString();
			}
			Iterator iter = getAnalyzers().keySet().iterator();
			while(iter.hasNext()){
				Analyzer ana = (Analyzer)getAnalyzers().get((String)iter.next());		
				isBad = ana.isBad(group);
				//System.out.println(isBad);
				if(isBad){
					break;
				}			
			}
				
		}
		return group.toString();
	}
	
	

}
